package com.hx.io.fileinputstream;

import java.io.*;

/**
 * @author jxlgcmh
 * @create 2019-05-09 16:46
 */
public class Demo2 {
    public static void main(String[] args) {
        File src = new File("D:\\HP\\Pictures\\梅岭\\IMG_1321.JPG");
        File dst = new File("D:\\HP\\Pictures\\梅岭\\IMG_1321副本.JPG");
        InputStream in = null;
        OutputStream out = null;
        try {
            in = new FileInputStream(src);
            out = new FileOutputStream(dst);
            int len;
            byte[] buf = new byte[1024];
            while ((len = in.read(buf)) != -1) {
                out.write(buf, 0, len);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (out != null) {
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
